const env = 'production';

const hosts = {
  development: '',
  production: 'https://as365.try0574.com/api/v1'
  //production: 'https://www.91ygp.com/api/v1'
}

const api = {
  user: {
    sessionKey: { //验证code
      method: 'GET',
      url: '/mini-program/session-key'
    },
    decode: {   //加密数据进行解密认证
      method: 'POST',
      url: '/mini-program/decode'
    },
    member: { //个人信息
      method: 'GET',
      url: '/member/member'
    },
    authentication: {   //实名认证
      method: 'POST',
      url: '/member/authentication'
    },
    sendCode: {   //手机验证码
      method: 'GET',
      url: '/member/authentication/send-code'
    },
    payInfo: { //专问支付信
        method: 'GET',
        url: '/member/lawyer-money/usermoney'
    },
    userPay: {
      method: 'POST',
      url: '/member/lawyer/pay'
    },
  },
  upload: {
    imagesUpload: { //图片上传
      method: 'POST',
      url: '/file/upload-images'
    },
    videosUpload: { //视频上传
      method: 'POST',
      url: '/file/upload-videos'
    },
    base64Upload: { //base64上传
      method: 'POST',
      url: '/file/upload-base64-img'
    },
  },
  regulation: {
    getRegulation: { //获取政策法规
      method: 'GET',
      url: '/base/regulation'
    },
    regulationDetail: { //获取政策法规详情
      method: 'GET',
      url: '/base/regulation/'
    },
  },
  contract: {
    contractSupervisor: { //合同监理创建
      method: 'POST',
      url: '/member/contract-supervisor'
    },
    contractDownLoad: { //合同下载列表
      method: 'GET',
      url: '/base/contract'
    },
    supervisor: { //合同监理列表
      method: 'GET',
      url: '/member/contract-supervisor'
    },
  },
  publicOption:{
    consensus:{
      method:'GET',//获取舆论列表
      url:'/contract/consensus'
    },
    consensusDetail:{
      method:'GET',//获取舆论详情
      url:'/contract/consensus/'
       },
    consensusModify:{
      method:'PUT',//舆论修改
      url:'/contract/consensus/'
    }
  },
  bidding:{
    biddinglist:{//招标市场列表
      method:'GET',
      url:'/contract/supervisor'
    },
    recieptbidding:{//接单
      method:'POST',
      url:'/contract/order'
    },
    tender:{//我的账户的 我的招标
      method:'GET',
      url:'/grade/tender'
    },  
  },
  connection:{
    connectionlist:{
      method:'GET',//获取人脉信息
      url:'/member/connection'
    },
    integrallist:{
      method:'GET',//积分明细
      url:'/member/integral'
    },
    notifylist:{
      method:'GET',//消息中心
      url:'/member/member-notify'
    }
  },
  lawyerdata:{
    lawyerList:{
      method:'GET',//获取律师列表
      url:'/member/lawyer'
    },
    lawyerDetail:{
      method:'GET',//获取律师详情
      url:'/member/lawyer/'
    },
    lawyerScoreList:{
      method:'GET',//获取律师评分列表
      url:'/member/lawyer-score'
    },
    lawyerMoneyList:{
      method:'GET',//获取律师所得费用列表
      url:'/member/lawyer-money'
    },
    giveLawyerMoney:{
      method:'POST',//律师获得费用
      url:'/member/lawyer-money'
    },
    lawyerArticleList:{
      method:'GET',//获取律师文章列表
      url:'/member/lawyer-article'
    },
    lawyerinfo:{
      method:'GET',//用户整合信息
      url:'/member/member-info/'
    },
    provincesList:{
      method:'GET',//获取省市
      url:'/base/provinces'
    }

  }
}

module.exports = {
  env,
  api: disposeUrl(api, hosts[env])
}

function disposeUrl(obj, prefix) {
  Object.keys(obj).forEach(v => {
    if (obj[v].url) {
      obj[v].url = prefix + obj[v].url
    } else {
      obj[v] = disposeUrl(obj[v], prefix)
    }
  })
  return obj
}